<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get the pattern used by the formatter</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="messageformatter.getlocale.html">MessageFormatter::getLocale</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="messageformatter.parsemessage.html">MessageFormatter::parseMessage</a></div>
 <div class="up"><a href="class.messageformatter.html">MessageFormatter</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="messageformatter.getpattern" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MessageFormatter::getPattern</h1>
  <h1 class="refname">msgfmt_get_pattern</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PECL intl &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">MessageFormatter::getPattern</span> -- <span class="refname">msgfmt_get_pattern</span> &mdash; <span class="dc-title">Get the pattern used by the formatter</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-messageformatter.getpattern-description">
  <h3 class="title">说明</h3>
  <p class="para">
   面向对象风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span> 
   <span class="methodname"><strong>MessageFormatter::getPattern</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   过程化风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> 
   <span class="methodname"><strong>msgfmt_get_pattern</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.messageformatter.html" class="type MessageFormatter">MessageFormatter</a></span> <code class="parameter">$fmt</code></span>
   )</div>

  <p class="para rdfs-comment">
   Get the pattern used by the formatter
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-messageformatter.getpattern-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">fmt</code></em></dt>

     <dd>

      <p class="para">
       The message formatter
      </p>
     </dd>

    
   </dl>

  </p>
 </div>



 <div class="refsect1 returnvalues" id="refsect1-messageformatter.getpattern-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The pattern <span class="type"><a href="language.types.string.html" class="type string">string</a></span> for this message formatter
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-messageformatter.getpattern-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-2518">
   <p><strong>Example #1 <span class="function"><strong>msgfmt_get_pattern()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fmt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">msgfmt_create</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"en_US"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"{0,&nbsp;number}&nbsp;monkeys&nbsp;on&nbsp;{1,&nbsp;number}&nbsp;trees"&nbsp;</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"Default&nbsp;pattern:&nbsp;'"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">msgfmt_get_pattern</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fmt&nbsp;</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"'\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Formatting&nbsp;result:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">msgfmt_format</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #0000BB">123</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">456</span><span style="color: #007700">)&nbsp;)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">msgfmt_set_pattern</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"{0,&nbsp;number}&nbsp;trees&nbsp;hosting&nbsp;{1,&nbsp;number}&nbsp;monkeys"&nbsp;</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"New&nbsp;pattern:&nbsp;'"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">msgfmt_get_pattern</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fmt&nbsp;</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"'\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Formatted&nbsp;number:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">msgfmt_format</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #0000BB">123</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">456</span><span style="color: #007700">)&nbsp;)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <div class="example" id="example-2519">
   <p><strong>Example #2 OO example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fmt&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MessageFormatter</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"en_US"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"{0,&nbsp;number}&nbsp;monkeys&nbsp;on&nbsp;{1,&nbsp;number}&nbsp;trees"&nbsp;</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"Default&nbsp;pattern:&nbsp;'"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getPattern</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">"'\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Formatting&nbsp;result:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(array(</span><span style="color: #0000BB">123</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">456</span><span style="color: #007700">))&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setPattern</span><span style="color: #007700">(</span><span style="color: #DD0000">"{0,&nbsp;number}&nbsp;trees&nbsp;hosting&nbsp;{1,&nbsp;number}&nbsp;monkeys"&nbsp;</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"New&nbsp;pattern:&nbsp;'"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getPattern</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">"'\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Formatted&nbsp;number:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(array(</span><span style="color: #0000BB">123</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">456</span><span style="color: #007700">))&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <p class="para">以上例程会输出：</p>
  <div class="example-contents screen">
<div class="cdata"><pre>
Default pattern: &#039;{0,number} monkeys on {1,number} trees&#039;
Formatting result: 123 monkeys on 456 trees
New pattern: &#039;{0,number} trees hosting {1,number} monkeys&#039;
Formatted number: 123 trees hosting 456 monkeys
</pre></div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-messageformatter.getpattern-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="messageformatter.create.html" class="function" rel="rdfs-seeAlso">msgfmt_create()</a> - Constructs a new Message Formatter</span></li>
    <li class="member"><span class="function"><a href="messageformatter.setpattern.html" class="function" rel="rdfs-seeAlso">msgfmt_set_pattern()</a> - Set the pattern used by the formatter</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="messageformatter.getlocale.html">MessageFormatter::getLocale</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="messageformatter.parsemessage.html">MessageFormatter::parseMessage</a></div>
 <div class="up"><a href="class.messageformatter.html">MessageFormatter</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
